﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using wsRK.BaseObject;
using wsRK.BusinessObjectHelper;

namespace nkstdgia.common.HoSoThamDinh
{
    public class HoSoThamDinhDataService : BaseDataService
    {
        #region Private members

        #endregion Private members

        #region Constructor

        public HoSoThamDinhDataService()
        {
        }

        #endregion Constructor

        #region Public Method

        public List<HoSoThamDinhInfo> searchHoSoThamDinh(
            string SO_PHIEU,
            string TRANGTHAI,
            string TEN_CHU_SU_DUNG,
            int QUANID,
            int PHUONGID,
            string DUONG,
            string DOANDUONG,
            float MIN_PRICE,
            float MAX_PRICE,
            int PageSize,
            int PageNo)
        {
            return CBO.FillCollection<HoSoThamDinhInfo>((IDataReader)SqlHelper.ExecuteReader(
              this.strConnectring,
                CommandType.StoredProcedure,
                "sproc_HO_SO_THAM_DINH_Search",
                new SqlParameter("@SO_PHIEU", SO_PHIEU),
                new SqlParameter("@TRANGTHAI", TRANGTHAI),
                new SqlParameter("@TEN_CHU_SU_DUNG", TEN_CHU_SU_DUNG),
                new SqlParameter("@QUANID", QUANID),
                new SqlParameter("@PHUONGID", PHUONGID),
                new SqlParameter("@DUONG", DUONG),
                new SqlParameter("@DOANDUONG", DOANDUONG),
                new SqlParameter("@MIN_PRICE", MIN_PRICE),
                new SqlParameter("@MAX_PRICE", MAX_PRICE),
                new SqlParameter("@PageSize", PageSize),
                new SqlParameter("@PageNo", PageNo)));
        }

        public List<HoSoThamDinhInfo> searchHoSoThamDinhByOwner(
            Guid USERID,
            string TRANGTHAI,
            int PageSize,
            int PageNo)
        {
            return CBO.FillCollection<HoSoThamDinhInfo>((IDataReader)SqlHelper.ExecuteReader(
             this.strConnectring,
                CommandType.StoredProcedure,
                "sproc_HO_SO_THAM_DINH_SearchByOwner",
                new SqlParameter("@USERID", USERID),
                new SqlParameter("@TRANGTHAI", TRANGTHAI),
                new SqlParameter("@PageSize", PageSize),
                new SqlParameter("@PageNo", PageNo)));
        }

        public int restoreHoSoThamDinh(int MA_HO_SO)
        {
            return SqlHelper.ExecuteNonQuery(
                this.strConnectring,
                CommandType.StoredProcedure,
                "sproc_HO_SO_THAM_DINH_Restore",
                new SqlParameter("@MA_HO_SO", MA_HO_SO));
        }        
        #endregion Public Method
    }
}